package com.song.invoicing.controller;

import com.song.invoicing.pojo.Result;
import com.song.invoicing.pojo.dto.UserLoginDTO;
import com.song.invoicing.pojo.dto.UserRegisterDTO;
import com.song.invoicing.pojo.UserAuthorization;
import com.song.invoicing.pojo.vo.UserVO;
import com.song.invoicing.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

     private final UserService userService;
     @PostMapping("/login")
     private Result<UserAuthorization> login(@RequestBody UserLoginDTO userLoginDTO)  {
         UserAuthorization userVO = userService.login(userLoginDTO);
          return Result.success(userVO);
     }
    @PostMapping("/register")
    private Result register(@RequestBody UserRegisterDTO userRegisterDTO)  {
        userService.register(userRegisterDTO);
        return Result.success("注册成功");
    }
    @GetMapping("/getUserInfo")
    private Result<UserVO> getUserInfo()  {
       return Result.success(userService.getUserInfo());
    }
}
